<!--
 * @Author: lp
 * @Date: 2022-01-12 14:32:43
 * @LastEditTime: 2022-04-15 15:38:56
 * @LastEditors: Please set LastEditors
 * @Description: svg组件
 * @FilePath: \nien-vue3-admin\src\components\svgIcon\index.vue
-->

<template>
  <svg aria-hidden="true" class="svg-icon-spin">
    <use :xlink:href="symbolId" :fill="color" />
  </svg>
</template>

<script lang="ts">
import { defineComponent, computed } from 'vue'

export default defineComponent({
  name: 'SvgIcon',
  props: {
    prefix: {
      type: String,
      default: 'icon',
    },
    name: {
      type: String,
      required: true,
    },
    color: {
      type: String,
      default: 'currentColor',
    },
  },
  setup(props) {
    const symbolId = computed(() => `#${ props.prefix }-${ props.name }`)
    return { symbolId }
  },
})
</script>
<style lang="less" scoped>
.svg-icon-spin {
  width: 1em;
  height: 1em;
  fill: currentcolor;
  vertical-align: middle;
}
</style>
